package cn.ffcs.uec.outStaff.component;

import lombok.Getter;
import lombok.Setter;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zkplus.databind.BindingListModelList;
import org.zkoss.zul.Div;
import org.zkoss.zul.ListModel;

import cn.ffcs.uec.outStaff.component.bean.UecOutStaffAndTrialListboxBean;
import cn.ffcs.uec.outStaff.constant.UecOutStaffConstants;
import cn.ffcs.uec.staff.manager.UecTrialManager;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.vo.PageInfo;

@Controller
@Scope("prototype")
public class UecOutStaffAndTrialListboxExt extends Div implements IdSpace {
	private static final long serialVersionUID = -1563542530430983406L;

	/**
	 * 对应页面上的bean
	 */
	private UecOutStaffAndTrialListboxBean bean = new UecOutStaffAndTrialListboxBean();

	private UecTrialManager uecTrialManager = (UecTrialManager) ApplicationContextUtil.getBean("uecTrialManager");

	@Getter
	@Setter
	private IPortletInfoProvider portletInfoProvider;

	public UecOutStaffAndTrialListboxExt() {
		Executions.createComponents(UecOutStaffConstants.UEC_OUT_STAFFTRIAL_EXT_LISTBOX_ZUL, this, null);
		Components.wireVariables(this, bean);
		Components.addForwards(this, this, '$');
	}

	/**
	 * 初始化
	 */
	public void onCreate() {
		onQueryUecOutStaffTrialList();
	}

	/**
	 * 翻页
	 */
	public void onUecOutStaffTrialListboxPaging() {
		this.onQueryUecOutStaffTrialList();
	}

	/**
	 * 查询
	 */
	public void onQueryUecOutStaffTrialList() {
		PageInfo pageInfo = uecTrialManager.queryPageInfo(
				this.bean.getUecOutStaffTrialListboxPaging().getActivePage() + 1,
				this.bean.getUecOutStaffTrialListboxPaging().getPageSize());
		ListModel list = new BindingListModelList(pageInfo.getDataList(), true);
		this.bean.getUecOutStaffTrialListbox().setModel(list);
		this.bean.getUecOutStaffTrialListboxPaging().setTotalSize(pageInfo.getTotalCount());

	}
}
